<?php
class ContractRewardVo extends SzAbstractMySqlVo
{

    private $userId;
    private $session;
    private $senior;
    private $generalSituation;
    private $seniorSituation;
    private $createTime;
    private $updateTime;
    private $endTime;

    /**
     * Initialize ContractRewardVo.
     *
     * @param $userId
     * @param $session
     * @param $senior
     * @param $generalSituation
     * @param $seniorSituation
     * @param $createTime
     * @param $updateTime
     * @param $endTime
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return ContractRewardVo
     */
    public function __construct($userId, $session, $senior, $generalSituation, $seniorSituation, $createTime, $updateTime, $endTime, $isInsert = false) {
        $this->userId = $userId;
        $this->session = $session;
        $this->senior = $senior;
        $this->generalSituation = json_decode($generalSituation, true);
        $this->seniorSituation = json_decode($seniorSituation, true);
        $this->createTime = $createTime;
        $this->updateTime = $updateTime;
        $this->endTime = $endTime;

        $this->isInsert = $isInsert;
        $this->voClassName = 'ContractRewardVo';
        $this->ormName = 'ContractReward';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'session' => $this->getSession(),
            'senior' => $this->getSenior(),
            'generalSituation' => ($needEncode) ? $this->getGeneralSituation() : $this->getRawGeneralSituation(),
            'seniorSituation' => ($needEncode) ? $this->getSeniorSituation() : $this->getRawSeniorSituation(),
            'createTime' => $this->getCreateTime(),
            'updateTime' => $this->getUpdateTime(),
            'endTime' => $this->getEndTime(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'session' => $this->getSession(),
            'senior' => $this->getSenior(),
            'generalSituation' => ($needEncode) ? $this->getGeneralSituation() : $this->getRawGeneralSituation(),
            'seniorSituation' => ($needEncode) ? $this->getSeniorSituation() : $this->getRawSeniorSituation(),
            'createTime' => $this->getCreateTime(),
            'updateTime' => $this->getUpdateTime(),
            'endTime' => $this->getEndTime(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getSession(),
            $this->getSenior(),
            $this->getGeneralSituation(),
            $this->getSeniorSituation(),
            $this->getCreateTime(),
            $this->getUpdateTime(),
            $this->getEndTime(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getSession()
    {
        return $this->session;
    }

    public function setSession($val)
    {
        $this->saveColumnStatus(1, $this->session);
        $this->session = $val;
    }

    public function getSenior()
    {
        return $this->senior;
    }

    public function setSenior($val)
    {
        $this->saveColumnStatus(2, $this->senior);
        $this->senior = $val;
    }

    public function getGeneralSituation()
    {
        return json_encode($this->generalSituation);
    }

    public function getRawGeneralSituation()
    {
        return $this->generalSituation;
    }

    public function setGeneralSituation($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[ContractRewardVo] The length of column generalSituation exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('ContractRewardVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[ContractRewardVo] The length of column generalSituation exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(3, $this->generalSituation);
        $this->generalSituation = $val;
    }

    public function getSeniorSituation()
    {
        return json_encode($this->seniorSituation);
    }

    public function getRawSeniorSituation()
    {
        return $this->seniorSituation;
    }

    public function setSeniorSituation($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[ContractRewardVo] The length of column seniorSituation exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('ContractRewardVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[ContractRewardVo] The length of column seniorSituation exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(4, $this->seniorSituation);
        $this->seniorSituation = $val;
    }

    public function getCreateTime()
    {
        return $this->createTime;
    }

    public function setCreateTime($val)
    {
        $this->saveColumnStatus(5, $this->createTime);
        $this->createTime = $val;
    }

    public function getUpdateTime()
    {
        return $this->updateTime;
    }

    public function setUpdateTime($val)
    {
        $this->saveColumnStatus(6, $this->updateTime);
        $this->updateTime = $val;
    }

    public function getEndTime()
    {
        return $this->endTime;
    }

    public function setEndTime($val)
    {
        $this->saveColumnStatus(7, $this->endTime);
        $this->endTime = $val;
    }

}